﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using UI.WinForm.Common;

namespace UI.WinForm.DayDatas
{
    public partial class frmDataLists : BaseForm
    {
        public frmDataLists()
        {
            InitializeComponent();
        }

        private void frmProducts_Load(object sender, EventArgs e)
        {
            DayDatasService _cs = new DayDatasService();
            this.dataGridView1.DataSource = _cs.GetProductsDataTable();

        }

        public DataSet SelectedProducts
        {
            get;
            private set;
        }

        private void bthReturnSelectedClients_Click(object sender, EventArgs e)
        {
            if (this.SelectedProducts != null)
                this.SelectedProducts = null;

            this.SelectedProducts = new DataSet();

            DataTable dt = new DataTable();
            dt.Columns.Add("ID", typeof(System.Int32));
            dt.Columns.Add("Name", typeof(System.String));
            dt.Columns.Add("Price", typeof(System.Double));

            this.SelectedProducts.Tables.Add(dt);

            foreach (var r in dataGridView1.SelectedRows)
            {
                DataRow dr = this.SelectedProducts.Tables[0].NewRow();

                dr["ID"] = int.Parse(((DataGridViewRow)r).Cells[0].Value.ToString());
                dr["Name"] = ((DataGridViewRow)r).Cells[1].Value.ToString();
                dr["Price"] = ((DataGridViewRow)r).Cells[2].Value.ToString();
                this.SelectedProducts.Tables[0].Rows.Add(dr);
            }
            this.Close();

        }
    }
}
